using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._CartographyTools._Generalization
{
    /// <summary>
    /// <para>Simplify Polygon</para>
    /// <para>Simplifies polygon features by removing relatively extraneous vertices while preserving essential shape.</para>
    /// <para>通过删除相对无关的折点，同时保留基本形状来简化面要素。</para>
    /// </summary>    
    [DisplayName("Simplify Polygon")]
    public class SimplifyPolygon : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public SimplifyPolygon()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_features">
        /// <para>Input Features</para>
        /// <para>The input polygon features to be simplified.</para>
        /// <para>要简化的输入面要素。</para>
        /// </param>
        /// <param name="_out_feature_class">
        /// <para>Output Feature Class</para>
        /// <para><xdoc>
        ///   <para>The simplified output polygon feature class. It contains all fields present in the input feature class. The output polygon feature class is topologically correct. The tool does not introduce topology errors, but topological errors in the input data are flagged in the output polygon feature class.</para>
        ///   <para>The output feature class includes two additional fields, InPoly_FID and SimPgnFlag, that contain the input feature IDs and the input topological errors or discrepancies, respectively.</para>
        ///   <para>SimPgnFlag attribute values are as follows:
        ///   <bulletList>
        ///     <bullet_item>SimPgnFlag = 0 indicates that no errors are present.  </bullet_item><para/>
        ///     <bullet_item>SimPgnFlag = 1 indicates a topological error is present.  </bullet_item><para/>
        ///     <bullet_item>SimPgnFlag = 2 indicates features that have been split by a partition and are now smaller than the minimum area after simplification. The flag may appear on only one part of the split feature. These features are all retained in the output feature class. This situation occurs only when the Cartographic Partitions environment setting is used.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>简化的输出面要素类。它包含输入要素类中存在的所有字段。输出面要素类在拓扑上是正确的。该工具不会引入拓扑错误，但输入数据中的拓扑错误会在输出面要素类中标记。</para>
        ///   <para>输出要素类包括两个附加字段 InPoly_FID 和 SimPgnFlag，它们分别包含输入要素 ID 和输入拓扑错误或差异。</para>
        /// <para>SimPgnFlag 属性值如下所示：
        ///   <bulletList>
        ///     <bullet_item>SimPgnFlag = 0 表示不存在任何错误。</bullet_item><para/>
        ///     <bullet_item>SimPgnFlag = 1 表示存在拓扑错误。</bullet_item><para/>
        ///     <bullet_item>SimPgnFlag = 2 表示已按分区分割的要素，并且在简化后现在小于最小面积。该标志只能出现在分割要素的一个部分上。这些要素都将保留在输出要素类中。仅当使用“制图分区”环境设置时，才会出现这种情况。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// </param>
        /// <param name="_algorithm">
        /// <para>Simplification Algorithm</para>
        /// <para><xdoc>
        ///   <para>Specifies the polygon simplification algorithm.</para>
        ///   <bulletList>
        ///     <bullet_item>Retain critical points (Douglas-Peucker)—Critical points that preserve the essential shape of a polygon outline are retained, and all other points are removed (Douglas-Peucker). This is the default.</bullet_item><para/>
        ///     <bullet_item>Retain critical bends (Wang-Müller)—Critical bends are retained, and extraneous bends are removed from a line (Wang-Müller).</bullet_item><para/>
        ///     <bullet_item>Retain weighted effective areas (Zhou-Jones)—Vertices that form triangles of effective area that have been weighted by triangle shape are retained (Zhou-Jones).</bullet_item><para/>
        ///     <bullet_item>Retain effective areas (Visvalingam-Whyatt)—Vertices that form triangles of effective area are retained (Visvalingam-Whyatt).</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定多边形简化算法。</para>
        ///   <bulletList>
        ///     <bullet_item>保留临界点 （Douglas-Peucker） - 保留多边形轮廓基本形状的临界点将保留，所有其他点将被移除 （Douglas-Peucker）。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>保留关键折弯 （Wang-Müller） - 保留关键折弯，并从线中移除无关折弯 （Wang-Müller）。</bullet_item><para/>
        ///     <bullet_item>保留加权有效面积 （周-Jones） - 保留形成已按三角形加权的有效面积三角形的顶点 （周-Jones）。</bullet_item><para/>
        ///     <bullet_item>保留有效面积 （Visvalingam-Whyatt） - 保留形成有效面积三角形的顶点 （Visvalingam-Whyatt）。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        /// <param name="_tolerance">
        /// <para>Simplification Tolerance</para>
        /// <para><xdoc>
        ///   <para>The tolerance determines the degree of simplification. You can choose a preferred unit; otherwise, units of the input will be used. The MinSimpTol and MaxSimpTol fields are added to the output to store the tolerance that was used when processing occurred.</para>
        ///   <bulletList>
        ///     <bullet_item>For the Retain critical points (Douglas-Peucker) algorithm, the tolerance is the maximum allowable perpendicular distance between each vertex and the newly created line.</bullet_item><para/>
        ///     <bullet_item>For the Retain critical bends (Wang-Müller) algorithm, the tolerance is the diameter of a circle that approximates a significant bend.</bullet_item><para/>
        ///     <bullet_item>For the Retain weighted effective areas (Zhou-Jones) algorithm, the square of the tolerance is the area of a significant triangle defined by three adjacent vertices. The further a triangle deviates from equilateral, the higher weight it is given, and the less likely it is to be removed.</bullet_item><para/>
        ///     <bullet_item>For the Retain effective areas (Visvalingam-Whyatt) algorithm, the square of the tolerance is the area of a significant triangle defined by three adjacent vertices.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>公差决定了简化的程度。您可以选择首选单位;否则，将使用输入的单位。MinSimpTol 和 MaxSimpTol 字段将添加到输出中，以存储发生处理时使用的容差。</para>
        ///   <bulletList>
        ///     <bullet_item>对于保留临界点 （Douglas-Peucker） 算法，容差是每个顶点与新创建的线之间的最大允许垂直距离。</bullet_item><para/>
        ///     <bullet_item>对于保留临界折弯 （Wang-Müller） 算法，公差是近似于有效折弯的圆的直径。</bullet_item><para/>
        ///     <bullet_item>对于保留加权有效面积 （周-Jones） 算法，公差的平方是由三个相邻顶点定义的有效三角形的面积。三角形偏离等边越远，赋予它的权重就越高，被移除的可能性就越小。</bullet_item><para/>
        ///     <bullet_item>对于保留有效面积 （Visvalingam-Whyatt） 算法，容差的平方是由三个相邻顶点定义的有效三角形的面积。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        public SimplifyPolygon(object _in_features, object _out_feature_class, _algorithm_value _algorithm, string? _tolerance)
        {
            this._in_features = _in_features;
            this._out_feature_class = _out_feature_class;
            this._algorithm = _algorithm;
            this._tolerance = _tolerance;
        }
        public override string ToolboxName => "Cartography Tools";

        public override string ToolName => "Simplify Polygon";

        public override string CallName => "cartography.SimplifyPolygon";

        public override List<string> AcceptEnvironments => ["MDomain", "XYDomain", "XYTolerance", "cartographicPartitions", "extent", "outputCoordinateSystem", "outputMFlag", "outputZFlag", "outputZValue", "scratchWorkspace", "workspace"];

        public override object[] ParameterInfo => [_in_features, _out_feature_class, _algorithm.GetGPValue(), _tolerance, _minimum_area, _error_option.GetGPValue(), _collapsed_point_option.GetGPValue(), _out_point_feature_class, _in_barriers];

        /// <summary>
        /// <para>Input Features</para>
        /// <para>The input polygon features to be simplified.</para>
        /// <para>要简化的输入面要素。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_features { get; set; }


        /// <summary>
        /// <para>Output Feature Class</para>
        /// <para><xdoc>
        ///   <para>The simplified output polygon feature class. It contains all fields present in the input feature class. The output polygon feature class is topologically correct. The tool does not introduce topology errors, but topological errors in the input data are flagged in the output polygon feature class.</para>
        ///   <para>The output feature class includes two additional fields, InPoly_FID and SimPgnFlag, that contain the input feature IDs and the input topological errors or discrepancies, respectively.</para>
        ///   <para>SimPgnFlag attribute values are as follows:
        ///   <bulletList>
        ///     <bullet_item>SimPgnFlag = 0 indicates that no errors are present.  </bullet_item><para/>
        ///     <bullet_item>SimPgnFlag = 1 indicates a topological error is present.  </bullet_item><para/>
        ///     <bullet_item>SimPgnFlag = 2 indicates features that have been split by a partition and are now smaller than the minimum area after simplification. The flag may appear on only one part of the split feature. These features are all retained in the output feature class. This situation occurs only when the Cartographic Partitions environment setting is used.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>简化的输出面要素类。它包含输入要素类中存在的所有字段。输出面要素类在拓扑上是正确的。该工具不会引入拓扑错误，但输入数据中的拓扑错误会在输出面要素类中标记。</para>
        ///   <para>输出要素类包括两个附加字段 InPoly_FID 和 SimPgnFlag，它们分别包含输入要素 ID 和输入拓扑错误或差异。</para>
        /// <para>SimPgnFlag 属性值如下所示：
        ///   <bulletList>
        ///     <bullet_item>SimPgnFlag = 0 表示不存在任何错误。</bullet_item><para/>
        ///     <bullet_item>SimPgnFlag = 1 表示存在拓扑错误。</bullet_item><para/>
        ///     <bullet_item>SimPgnFlag = 2 表示已按分区分割的要素，并且在简化后现在小于最小面积。该标志只能出现在分割要素的一个部分上。这些要素都将保留在输出要素类中。仅当使用“制图分区”环境设置时，才会出现这种情况。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Feature Class")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _out_feature_class { get; set; }


        /// <summary>
        /// <para>Simplification Algorithm</para>
        /// <para><xdoc>
        ///   <para>Specifies the polygon simplification algorithm.</para>
        ///   <bulletList>
        ///     <bullet_item>Retain critical points (Douglas-Peucker)—Critical points that preserve the essential shape of a polygon outline are retained, and all other points are removed (Douglas-Peucker). This is the default.</bullet_item><para/>
        ///     <bullet_item>Retain critical bends (Wang-Müller)—Critical bends are retained, and extraneous bends are removed from a line (Wang-Müller).</bullet_item><para/>
        ///     <bullet_item>Retain weighted effective areas (Zhou-Jones)—Vertices that form triangles of effective area that have been weighted by triangle shape are retained (Zhou-Jones).</bullet_item><para/>
        ///     <bullet_item>Retain effective areas (Visvalingam-Whyatt)—Vertices that form triangles of effective area are retained (Visvalingam-Whyatt).</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定多边形简化算法。</para>
        ///   <bulletList>
        ///     <bullet_item>保留临界点 （Douglas-Peucker） - 保留多边形轮廓基本形状的临界点将保留，所有其他点将被移除 （Douglas-Peucker）。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>保留关键折弯 （Wang-Müller） - 保留关键折弯，并从线中移除无关折弯 （Wang-Müller）。</bullet_item><para/>
        ///     <bullet_item>保留加权有效面积 （周-Jones） - 保留形成已按三角形加权的有效面积三角形的顶点 （周-Jones）。</bullet_item><para/>
        ///     <bullet_item>保留有效面积 （Visvalingam-Whyatt） - 保留形成有效面积三角形的顶点 （Visvalingam-Whyatt）。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Simplification Algorithm")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _algorithm_value _algorithm { get; set; }

        public enum _algorithm_value
        {
            /// <summary>
            /// <para>Retain critical points (Douglas-Peucker)</para>
            /// <para>Retain critical points (Douglas-Peucker)—Critical points that preserve the essential shape of a polygon outline are retained, and all other points are removed (Douglas-Peucker). This is the default.</para>
            /// <para>保留临界点 （Douglas-Peucker） - 保留多边形轮廓基本形状的临界点将保留，所有其他点将被移除 （Douglas-Peucker）。这是默认设置。</para>
            /// </summary>
            [Description("Retain critical points (Douglas-Peucker)")]
            [GPEnumValue("POINT_REMOVE")]
            _POINT_REMOVE,

            /// <summary>
            /// <para>Retain critical bends (Wang-Müller)</para>
            /// <para>Retain critical bends (Wang-Müller)—Critical bends are retained, and extraneous bends are removed from a line (Wang-Müller).</para>
            /// <para>保留关键折弯 （Wang-Müller） - 保留关键折弯，并从线中移除无关折弯 （Wang-Müller）。</para>
            /// </summary>
            [Description("Retain critical bends (Wang-Müller)")]
            [GPEnumValue("BEND_SIMPLIFY")]
            _BEND_SIMPLIFY,

            /// <summary>
            /// <para>Retain weighted effective areas (Zhou-Jones)</para>
            /// <para>Retain weighted effective areas (Zhou-Jones)—Vertices that form triangles of effective area that have been weighted by triangle shape are retained (Zhou-Jones).</para>
            /// <para>保留加权有效面积 （周-Jones） - 保留形成已按三角形加权的有效面积三角形的顶点 （周-Jones）。</para>
            /// </summary>
            [Description("Retain weighted effective areas (Zhou-Jones)")]
            [GPEnumValue("WEIGHTED_AREA")]
            _WEIGHTED_AREA,

            /// <summary>
            /// <para>Retain effective areas (Visvalingam-Whyatt)</para>
            /// <para>Retain effective areas (Visvalingam-Whyatt)—Vertices that form triangles of effective area are retained (Visvalingam-Whyatt).</para>
            /// <para>保留有效面积 （Visvalingam-Whyatt） - 保留形成有效面积三角形的顶点 （Visvalingam-Whyatt）。</para>
            /// </summary>
            [Description("Retain effective areas (Visvalingam-Whyatt)")]
            [GPEnumValue("EFFECTIVE_AREA")]
            _EFFECTIVE_AREA,

        }

        /// <summary>
        /// <para>Simplification Tolerance</para>
        /// <para><xdoc>
        ///   <para>The tolerance determines the degree of simplification. You can choose a preferred unit; otherwise, units of the input will be used. The MinSimpTol and MaxSimpTol fields are added to the output to store the tolerance that was used when processing occurred.</para>
        ///   <bulletList>
        ///     <bullet_item>For the Retain critical points (Douglas-Peucker) algorithm, the tolerance is the maximum allowable perpendicular distance between each vertex and the newly created line.</bullet_item><para/>
        ///     <bullet_item>For the Retain critical bends (Wang-Müller) algorithm, the tolerance is the diameter of a circle that approximates a significant bend.</bullet_item><para/>
        ///     <bullet_item>For the Retain weighted effective areas (Zhou-Jones) algorithm, the square of the tolerance is the area of a significant triangle defined by three adjacent vertices. The further a triangle deviates from equilateral, the higher weight it is given, and the less likely it is to be removed.</bullet_item><para/>
        ///     <bullet_item>For the Retain effective areas (Visvalingam-Whyatt) algorithm, the square of the tolerance is the area of a significant triangle defined by three adjacent vertices.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>公差决定了简化的程度。您可以选择首选单位;否则，将使用输入的单位。MinSimpTol 和 MaxSimpTol 字段将添加到输出中，以存储发生处理时使用的容差。</para>
        ///   <bulletList>
        ///     <bullet_item>对于保留临界点 （Douglas-Peucker） 算法，容差是每个顶点与新创建的线之间的最大允许垂直距离。</bullet_item><para/>
        ///     <bullet_item>对于保留临界折弯 （Wang-Müller） 算法，公差是近似于有效折弯的圆的直径。</bullet_item><para/>
        ///     <bullet_item>对于保留加权有效面积 （周-Jones） 算法，公差的平方是由三个相邻顶点定义的有效三角形的面积。三角形偏离等边越远，赋予它的权重就越高，被移除的可能性就越小。</bullet_item><para/>
        ///     <bullet_item>对于保留有效面积 （Visvalingam-Whyatt） 算法，容差的平方是由三个相邻顶点定义的有效三角形的面积。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Simplification Tolerance")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public string? _tolerance { get; set; }


        /// <summary>
        /// <para>Minimum Area</para>
        /// <para>The minimum area for a polygon to be retained. The default value is zero, that is, to keep all polygons. You can choose a preferred unit for the specified value; otherwise, units of the input will be used.</para>
        /// <para>要保留的面的最小面积。默认值为零，即保留所有多边形。您可以为指定值选择首选单位;否则，将使用输入的单位。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Minimum Area")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _minimum_area { get; set; } = null;


        /// <summary>
        /// <para>Handling Topological Errors</para>
        /// <para>This is a legacy parameter that is no longer used. It was formerly used to specify how topological errors possibly introduced during processing were handled. This parameter is still included in the tool's syntax for compatibility in scripts and model but is hidden from the tool's dialog box.</para>
        /// <para>这是不再使用的旧参数。它以前用于指定如何处理处理过程中可能引入的拓扑错误。此参数仍包含在工具的语法中，以便在脚本和模型中兼容，但在工具的对话框中隐藏。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Handling Topological Errors")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _error_option_value _error_option { get; set; } = _error_option_value._RESOLVE_ERRORS;

        public enum _error_option_value
        {
            /// <summary>
            /// <para>NO_CHECK</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_CHECK")]
            [GPEnumValue("NO_CHECK")]
            _NO_CHECK,

            /// <summary>
            /// <para>FLAG_ERRORS</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("FLAG_ERRORS")]
            [GPEnumValue("FLAG_ERRORS")]
            _FLAG_ERRORS,

            /// <summary>
            /// <para>RESOLVE_ERRORS</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("RESOLVE_ERRORS")]
            [GPEnumValue("RESOLVE_ERRORS")]
            _RESOLVE_ERRORS,

        }

        /// <summary>
        /// <para>Keep collapsed points</para>
        /// <para><xdoc>
        ///   <para>Specifies whether an output point feature class will be created to store the centers of polygons that are removed because they are smaller than the Minimum area parameter value. The point output is derived; it will use the same name and location as the Output feature class parameter but with a _Pnt suffix.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—A derived output point feature class will be created to store the centers of polygons that are removed because they are smaller than the minimum area. This is the default.</bullet_item><para/>
        ///     <bullet_item>Unchecked—A derived output point feature class will not be created.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定是否创建输出点要素类来存储因小于最小面积参数值而移除的面中心。推导点输出;它将使用与输出要素类参数相同的名称和位置，但带有_Pnt后缀。</para>
        ///   <bulletList>
        ///     <bullet_item>选中 - 将创建派生输出点要素类，以存储因小于最小面积而被移除的面的中心。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>未选中 - 不会创建派生输出点要素类。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Keep collapsed points")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _collapsed_point_option_value _collapsed_point_option { get; set; } = _collapsed_point_option_value._true;

        public enum _collapsed_point_option_value
        {
            /// <summary>
            /// <para>KEEP_COLLAPSED_POINTS</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("KEEP_COLLAPSED_POINTS")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_KEEP</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_KEEP")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Polygons Collapsed To Zero Area</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Polygons Collapsed To Zero Area")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _out_point_feature_class { get; set; }


        /// <summary>
        /// <para>Input Barrier Layers</para>
        /// <para>The inputs containing features to act as barriers for simplification. Resulting simplified polygons will not touch or cross barrier features. For example, when simplifying forested areas, the resulting simplified forest polygons will not cross road features defined as barriers.</para>
        /// <para>包含作为简化障碍的功能的输入。生成的简化面不会接触或穿过障碍要素。例如，在简化森林区域时，生成的简化森林面不会与定义为障碍物的道路要素相交。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Barrier Layers")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public List<object> _in_barriers { get; set; } = null;


        public SimplifyPolygon SetEnv(object MDomain = null, object XYDomain = null, object XYTolerance = null, object cartographicPartitions = null, object extent = null, object outputCoordinateSystem = null, object outputMFlag = null, object outputZFlag = null, object outputZValue = null, object scratchWorkspace = null, object workspace = null)
        {
            base.SetEnv(MDomain: MDomain, XYDomain: XYDomain, XYTolerance: XYTolerance, cartographicPartitions: cartographicPartitions, extent: extent, outputCoordinateSystem: outputCoordinateSystem, outputMFlag: outputMFlag, outputZFlag: outputZFlag, outputZValue: outputZValue, scratchWorkspace: scratchWorkspace, workspace: workspace);
            return this;
        }

    }

}